package com.example.demo.common;

import java.util.HashMap;

//自定义的统一返回对象格式
public class Result {
    //业务处理成功的时候执行的方法
    public static HashMap<String,Object>success(Object data) {
        HashMap<String,Object>result =new HashMap<>();
        result.put("code",200);
        result.put("msg","");
        result.put("data",data);
        return result;
    }
    public static HashMap<String,Object>success(String msg,Object data) {
        HashMap<String,Object>result =new HashMap<>();
        result.put("code",200);
        result.put("msg",msg);
        result.put("data",data);
        return result;
    }

    //业务处理失败的时候执行的方法
    public static HashMap<String,Object>fail(int code,String msg) {
        HashMap<String,Object>result =new HashMap<>();
        result.put("code",code);
        result.put("msg",msg);
        result.put("data","");
        return result;
    }
}
